package il.ac.mta.javaweb.ex1.logic;

import il.ac.mta.javaweb.ex1.logic.grids.MarkingGrid;
import il.ac.mta.javaweb.ex1.logic.players.PlayerBase;

import java.util.ArrayList;
import java.util.List;

public class BattleShipsGame
{
	public static final int MIN_NUM_OF_PLAYERS = 2;
	public static final int MAX_NUM_OF_PLAYERS = 6;

	private List<PlayerBase> players;

	public void Init(List<PlayerBase> players)
	{
		this.players = players;

		for (PlayerBase player : players)
		{
			player.getEnemiesMarkingGrids().clear();
			player.getOwnGrid().reinitGrid();
		}		
		
		for (PlayerBase player : players)
		{
			for (PlayerBase otherPlayer : players)
			{
				if (!player.equals(otherPlayer))
				{
					player.addEnemyGrid(new MarkingGrid(otherPlayer.getOwnGrid(), otherPlayer));
				}
			}
		}
	}

	public List<PlayerBase> getPlayers()
	{
		return players;
	}

	public void reset()
	{
		this.players = new ArrayList<PlayerBase>();
	}
}
